<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>

<div class="pad_10">
<div id="searchid">
<form name="searchform" action="" method="get" >
<input type="hidden" value="comment_nsr" name="m">
<input type="hidden" value="manage" name="c">
<input type="hidden" value="init" name="a">
<input type="hidden" value="1" name="search">
<input type="hidden" value="<?php echo $_SESSION['pc_hash']?>" name="pc_hash">
<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td>
		<div class="explain-col">	
			<?php echo L('comment_type')?>：<select name="comment_type" onchange="show_tbl(this)">
				<option value='1' <?php if($comment_type == 1) echo 'selected';?>><?php echo L('news')?></option>
				<option value='2' <?php if($comment_type == 2) echo 'selected';?>><?php echo L('pictures')?></option>
				<option value='3' <?php if($comment_type == 3) echo 'selected';?>><?php echo L('video')?></option>
				<option value='4' <?php if($comment_type == 4) echo 'selected';?>><?php echo L('talent')?></option>
				<option value='5' <?php if($comment_type == 5) echo 'selected';?>><?php echo L('contest')?></option>
				<option value='6' <?php if($comment_type == 6) echo 'selected';?>><?php echo L('activity')?></option>
				<option value='7' <?php if($comment_type == 7) echo 'selected';?>><?php echo L('train')?></option>
				<option value='8' <?php if($comment_type == 8) echo 'selected';?>><?php echo L('course')?></option>
			</select>
			<?php echo L('username');?>:
			<input name="keyword" type="text" value="<?php if(isset($keywords)) echo $keywords;?>" class="input-text" />
			<?php echo L('comment_con');?>:
			<input name="comment_con" type="text" value="<?php if(isset($comment_con)) echo $comment_con;?>" class="input-text" />
			<?php echo L('publish_time');?>：
			<?php echo form::date('start_time',$_GET['start_time'],0,0,'false');?>- &nbsp;<?php echo form::date('end_time',$_GET['end_time'],0,0,'false');?>
			<input type="submit" name="search" class="button" value="<?php echo L('search');?>" />
		</div>
		</td>
		</tr>
    </tbody>
</table>
</form>
</div>
</div>
<div class="pad-lr-10">
<form name="myform" id="myform" action="" method="get" onsubmit="return confirm('<?php echo L('confirm')?>')">
<input type="hidden" value="comment_nsr" name="m">
<input type="hidden" value="manage" name="c">
<input type="hidden" value="del" name="a">
<div class="table-list comment">
    <table width="100%">
        <thead>
            <tr>
			 <th width="16"><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');"></th>
			<th width="130"><?php echo L('author')?></th>
			<th><?php echo L('comment')?></th>
			<th width="230"><?php echo L('original').L('title');?></th>
			<th width="72"><?php echo L('status');?></th>
			<th width="72"><?php echo L('checked_by');?></th>
			<th width="72"><?php echo L('checked_time');?></th>
			<th width="72"><?php echo L('operations_manage');?></th>
            </tr>
        </thead>
		<tbody class="add_comment">
    <?php
    if(is_array($comment_info)) {
    	if(!empty($comment_info)){
    	foreach($comment_info as $v) {
    		$original_info = $this->source_db->get_one(array('id'=>$v['source_id']));
	?>
     <tr id="tbody_<?php echo $v['id']?>">
		<td align="center" width="16"><input class="inputcheckbox " name="id[]" value="<?php echo $v['id'];?>" type="checkbox"></td> 
		<td width="130" align="center"><?php echo $v['username']?$v['username']:'游客';?><br /><?php echo $v['ip']?></td>
		<td><font color="#888888"><?php echo L('chez')?> <?php echo $v['create_time']?> <?php echo L('release')?></font><br /><?php echo $v['content']?></td>
		<?php if($comment_type ==1 || $comment_type ==2 ||$comment_type == 3){?>
		<td width="230" title='<?php echo $original_info['title'];?>'><?php echo str_cut($original_info['title'],45);?></td>
		<?php }elseif($comment_type == 4){?>
		<td width="230"><?php echo substr($original_info['real_name'],0,40)?></td>
		<?php }elseif($comment_type == 5 || $comment_type == 6 || $comment_type == 7){?>
		<td width="230"><?php echo substr($original_info['name'],0,40)?></td>
		<?php }elseif($comment_type == 8){?>
		<td width="230"><?php echo substr($original_info['full_name'],0,40)?></td>
		<?php }?>
		<td align='center' width="72">
			<?php if($v['status']==1){
				echo '<font color="green">审核通过</font>';
			}elseif($v['status']==2){
				echo '<font color="red">审核未通过!</font>';
			}elseif($v['status']==3){
				echo '待审核';
			}?>
		</td>
		<td align='center' width="72"><?php if(!empty($v['checked_by'])){echo $adminInfo[$v['checked_by']];}else{echo '<font color="red">(暂无数据)</font>';}?></td>
		<td align='center' width="150"><?php if(!empty($v['checked_time'])){echo $v['checked_time'];}else{echo '<font color="red">(暂无数据)</font>';}?></td>
		<td align='center' width="72">
		<?php if($v['status'] == 1 || $v['status'] == 2){?>
		<a href="?m=comment_nsr&c=manage&a=del&id=<?php echo $v['id']?>&comment_type=<?php echo $comment_type?>" onclick="return check(<?php echo $v['id']?>)"><?php echo L('delete');?></a>
		<?php }else{?>
			<a href="?m=comment_nsr&c=manage&a=check&id=<?php echo $v['id']?>&comment_type=<?php echo $comment_type?>&pass=0"><?php echo L('pass');?></a>
			<br/>
			<a href="?m=comment_nsr&c=manage&a=check&id=<?php echo $v['id']?>&comment_type=<?php echo $comment_type?>&pass=1"><?php echo L('no_pass');?></a>
			<br/>
			<a href="?m=comment_nsr&c=manage&a=del&id=<?php echo $v['id']?>&comment_type=<?php echo $comment_type?>" onclick="return check(<?php echo $v['id']?>)"><?php echo L('delete');?></a>
		<?php }?>
		</td>
	</tr>
     <?php }
    	}else{
    		echo "<tr><td colspan='10' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>";
    	}
	}
	?>
	</tbody>
     </table>
    <div class="btn"><label for="check_box"><?php echo L('selected_all');?>/<?php echo L('cancel');?></label>
		<input type="hidden" value="<?php echo $_SESSION['pc_hash'];?>" name="pc_hash">
		<input type="submit" class="button" value="<?php echo L('delete');?>" />
		<input type="button" class="button" onclick="check_all(1)" value="<?php echo '通过';?>" />
		<input type="button" class="button" onclick="check_all(2)" value="<?php echo '不通过';?>" />
	</div>
    <div id="pages"><?php echo $pages;?></div>
</div>
</form>
</div>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<script type="text/javascript">
function check(id) {
	if(!confirm('<?php echo L('are_you_sure_you_want_to_delete')?>')) {
		return false;
	}
	return true;
}
function show_tbl(obj) {
	var comment_type = $(obj).val();
	location.href='?m=comment_nsr&c=manage&a=init&comment_type='+comment_type+'&pc_hash=<?php echo $_SESSION['pc_hash']?>';
}
function check_all(flag) {
	var cids = '';
	$('.inputcheckbox').each(function(){
	    if(this.checked){
	        cids = cids + this.value + ',';
	    }
	});
	if(cids.length == 0){
		alert('请先选择要审核的评论！');
		return false;
	}
	cids = cids.substring(0,cids.length-1);
	$.ajax({
		type:"get",
		url:"?m=comment_nsr&c=manage&a=check_all&flag="+flag+"&cids="+cids+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
		dataType: "json",
		success:function(data){
			if(data['status']){
				window.location.reload();
			}else{
				alert(data['msg']);
				return false;
			}
		}
	})
}

/*
 *function：根据cookie值来判断表单、ajax等成功执行时，重新加载窗口 
 * author：吴发顶
 * time：2017-06-08 10:56:13
 */
setcookie('refersh_time', 0);
function refersh_window() {
	var refersh_time = getcookie('refersh_time');
	if(refersh_time==1) {
		window.location.reload();
	}
}
setInterval("refersh_window()", 3000);
</script>
</body>
</html>